<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDataSourcesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('data_sources', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('parent_id')->default('0')->comment('父结点');
            $table->string('name')->default('')->comment('名称');
            $table->string('aliasname')->default('')->comment('别名');
            $table->string('realname')->default('')->nullable()->comment('真实名');
            $table->integer('type_id')->default('0')->nullable()->comment('数据源类型1字段,2数据库,3文件,4接口,5数据源');
            $table->integer('data_type_id')->default('0')->nullable()->comment('数据类型1数组,2对象');
            $table->integer('field_type_id')->default('0')->nullable()->comment('字段类型1字符串,2数字,3时间,4日期,5json,6自定义字段');
            $table->integer('decimal_digits')->default('0')->nullable()->comment('小数位数');
            $table->string('format')->default('')->nullable()->comment('格式化');
            $table->text('field_value')->nullable()->comment('字段值');
            $table->text('db_sql')->nullable()->comment('数据库查询');
            $table->integer('file_server_id')->default('0')->nullable()->comment('文件服务器');
            $table->string('file_path')->nullable()->comment('文件路径');
            $table->integer('file_type_id')->default('0')->nullable()->comment('文件类型1excel,2tsv,3csv');
            $table->integer('title_line')->default('0')->nullable()->comment('标题行数');
            $table->integer('api_req_type')->default('0')->nullable()->comment('接口类型1get,2post');
            $table->string('api_parameter')->nullable()->comment('参数');
            $table->integer('data_source_id')->default('0')->nullable()->comment('数据源');
            $table->mediumText('script')->nullable()->comment('脚本');
            $table->integer('reviewer_id')->default('0')->nullable()->comment('审核人');
            $table->dateTime('review_time')->nullable()->comment('审核时间');
            $table->integer('status')->default('0')->comment('状态1通过,2未通过');
            $table->integer('order')->default('0')->comment('排序');
            $table->integer('creator_id')->default('0')->comment('创建者');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('data_sources');
    }
}
